Skip to content

[fix] photo upload body limit + shared client preflight#44

Merged
peterabcd merged 1 commit into
mainfrom
fix/upload-body-limit
Jun 7, 2026
Merged

[fix] photo upload body limit + shared client preflight#44
peterabcd merged 1 commit into
mainfrom
fix/upload-body-limit

Conversation

@peterabcd

Copy link
Copy Markdown
Collaborator

제보고 된 버그

1 MB 쇬 넘는 JPG 를 단체사진으로 올리면 prod 에서 Application error (digest 4028661507) 가 떴던 현상. 서버 로그로 원인 확정:

Error: Body exceeded 1 MB limit.
statusCode: 413
digest: '4028661507'

즉 우리 코드의 MAX_UPLOAD_BYTES = 15MB 검증까지 도달하지 못하고 Next Server Actions 기본 1 MB 제한에 먼저 잡혐다.

수정

  • next.config.tsexperimental.serverActions.bodySizeLimit: "20mb" 추가. 우리 상한(15MB) + multipart overhead 마진.
  • lib/upload-limits.ts 신규 — client/server 둘 다 import 가능한 pure 상수(MAX_UPLOAD_BYTES, ALLOWED_MIME_TYPES) + preflight 헬퍼(checkUploadFile). 기존 lib/uploads.ts 는 이 모듈에서 re-export + 내부에서 사용.
  • PhotoSection.tsx / PhotoReplaceButton.tsxclient preflight 추가. 파일 선택 단계에서 size/MIME 를 검사해 통과 못하면 server action 호출 자체를 안 한다 — generic 413 차단 + 빠른 inline 알림.
  • photo-actions.ts 교체 — 동일한 checkUploadFile 을 server-side 에서도 다시 수행 (defense in depth, client preflight 우회 대비).

잘이니 버그 점검

같은 종류의 잠재 버그(framework 기본 limit 에 걸리는 경우)가 다른 server action 에 있는지 확인:

  • createSession (notes 최대 2000자 = ~4KB) — 안전.
  • upsertParticipation (note 500자) — 안전.
  • approveUser / rejectUser — userId 하나. 안전.
  • uploadSessionPhoto / removeSessionPhoto — 본 PR 에서 수정.

즉 1 MB 경계에 걸리는 server action 은 사진 업로드 둘 뿐이고, 둔 PR 에서 모두 고쳐짐.

middleware 쪽은 이미 #43 에서 /admin Edge 차단 제거 + page-level requireAdmin() 에서 최종 판정 하도록 정리됨. stale token 가능성이 있던 /admin/* 점검 걹처가 이제 없음.

머릿속 검증

  • 0 KB 파일 → "빈 파일입니다." inline
  • 18 MB JPG → 선택 즉시 client preflight 에서 "파일이 너무 큽니다 ..." inline (서버 갈 필요 X)
  • 4 MB JPG → 정상 업로드, 기존 generic 413 안 뜨야 함
  • HEIC → MIME 매칭되면 업로드
  • 임의 .txt → client preflight 에서 "지원하지 않는 파일 형식" inline

문서 보강

  • .gjc/skills/murun-feature/SKILL.md §4.5 에 파일 업로드 체크리스트 추가 (bodySizeLimit + client preflight + defense in depth + 공유 상수).
  • docs/wiki/06-Checkpoints.md £7 에 "파일 업로드 framework limit 경계" 항목 추가.

검증

  • pnpm check 통과.
  • main 머지 후 N100 쪽은 자동 배포만으로도 붙습되어야 함 (.env.prod 에 추가 설정 필요 없음).

@peterabcd peterabcd merged commit e76b50b into main Jun 7, 2026
1 check passed
@peterabcd peterabcd deleted the fix/upload-body-limit branch June 7, 2026 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant